var getIntersectionNode = function(headA, headB) {
    if((!headA)||(!headB)) return null
    let pA=headA,
        pB=headB;
    let i=1,
        j=1;
    
    while(pA.next){
        pA=pA.next
        i++
    }
    while(pB.next){
        pB=pB.next
        j++
    }

    if(pB!=pA){
        return null
    } 
    else{
        pA=headA
        pB=headB
        if(i>j){
            while(i-j>0){
                pA=pA.next
                i--
            }
        }else{
            while(j-i>0){
                pB=pB.next
                j--
            }
        }
        while(pA!=pB){
            pA=pA.next
            pB=pB.next
        }
        return pA
    }
   
};